﻿using PunchCard.Model;
using PunchCard.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace PunchCard.View
{
    /// <summary>
    /// InputTextDlg.xaml 的交互逻辑
    /// </summary>
    public partial class InputTextDlg : Window
    {
        public InputTextDlg()
        {
            InitializeComponent();
            Year.Text= MODELFUNC.m_nYear.ToString();
            Month.Text = MODELFUNC.m_nMonth.ToString();
            ID.Text = MODELFUNC.m_strID;
            Name.Text = MODELFUNC.m_strName;
            if (MODELFUNC.m_nModel == 2 && !MODELFUNC.m_bBatchModel)
            {
                ID.Visibility = Visibility.Visible;
                this.Height = 180;
            }
            else
            {
                this.Height = 120;
            }
            this.Width = 320;
            WindowStartupLocation = WindowStartupLocation.CenterScreen;
        }

        private ModelMainWindow MODELFUNC = ViewModel.ViewModel.GetInstance().m_Model_MainWindow;


        private void Commit(object sender, RoutedEventArgs e)
        {
            MODELFUNC.m_nYear = int.Parse(Year.Text);
            MODELFUNC.m_nMonth = int.Parse(Month.Text);
            MODELFUNC.m_strID = ID.Text;
            MODELFUNC.m_strName = Name.Text;
            

            DialogResult = true;
            Close();
        }

        private void Cancel(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
        }
    }
}
